package visiopuce.graph;

import java.awt.Point;
import java.awt.geom.Point2D;

import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.PlotRenderingInfo;
import org.jfree.chart.plot.Zoomable;
import org.jfree.experimental.chart.swt.ChartComposite;

public class MyChartPanel extends ChartComposite {

	private Long defaultLowerBoundX;
	private Long defaultUpperBoundX;

	private double maxBoundY;
	private double minBoundY;
	private double maxBoundX;
	private double minBoundX;
	private GraphCytog graph;

	public MyChartPanel(GraphCytog graph, Composite comp, int style, JFreeChart jfreechart, int width, int height, int minimumDrawW, int minimumDrawH, int maximumDrawW, int maximumDrawH, boolean usingBuffer, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips) {
		super(comp, style, jfreechart, width, height, minimumDrawW, minimumDrawH, maximumDrawW, maximumDrawH, usingBuffer, properties, save, print, zoom, tooltips);
		this.graph = graph;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = -8369305115022784032L;

	public void restoreAutoDomainBounds() {
		getChart().getXYPlot().getDomainAxis().setLowerBound(defaultLowerBoundX);
		getChart().getXYPlot().getDomainAxis().setUpperBound(defaultUpperBoundX);
		graph.updateTaille();
	}

	public void setDefaultLowerBoundX(Long defaultLowerBoundX) {
		this.defaultLowerBoundX = defaultLowerBoundX;
	}

	public Long getDefaultUpperBoundX() {
		return defaultUpperBoundX;
	}

	public void setDefaultUpperBoundX(Long defaultUpperBoundX) {
		this.defaultUpperBoundX = defaultUpperBoundX;
	}

	public Long getDefaultLowerBoundX() {
		return defaultLowerBoundX;
	}

	public void setMinBoundY(double minBoundY) {
		this.minBoundY = minBoundY;
	}

	public double getMaxBoundY() {
		return maxBoundY;
	}

	public void setMaxBoundY(double maxBoundY) {
		this.maxBoundY = maxBoundY;
	}

	public double getMinBoundY() {
		return minBoundY;
	}

	public void setMinBoundX(double minBoundX) {
		this.minBoundX = minBoundX;
	}

	public double getMaxBoundX() {
		return maxBoundX;
	}

	public void setMaxBoundX(double maxBoundX) {
		this.maxBoundX = maxBoundX;
	}

	public double getMinBoundX() {
		return minBoundX;
	}

	@Override
	public void restoreAutoBounds() {
		restoreAutoDomainBounds();
		// restoreAutoRangeBounds();
	}

	/**
	 * Zooms in on a selected region.
	 * 
	 * @param selection
	 *            the selected region.
	 */
	public void zoom(Rectangle selection) {
		super.zoom(selection);
		graph.updateTaille();

	}

}
